package top.api.config;
 
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
 
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 参数校验配置类
 *@Author yql
 *@Data 2023-03-04 11:21
 *@Description
 */
@Configuration
public class ValidatedConfig {
 
	@Bean
	public Validator validator() {
		ValidatorFactory vfactory = Validation.byProvider(HibernateValidator.class)
				.configure()
				.failFast(true)//开启快速失败
				.buildValidatorFactory();
		return vfactory.getValidator();
		
	}
	
}